import 'package:fate_blind_box/theme/theme_color.dart';
import 'package:fate_blind_box/utils/common_widget.dart';
import 'package:flutter/material.dart';

class ActSignSetView extends StatefulWidget {
  Function? callBack;

  ActSignSetView({this.callBack, Key? key}) : super(key: key);

  @override
  State<ActSignSetView> createState() => _ActSignSetViewState();
}

class _ActSignSetViewState extends State<ActSignSetView> {
  TextEditingController nameController = TextEditingController(); //姓名
  TextEditingController phoneController = TextEditingController(); //电话
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        AppWidget.navTitleBar(
          title: '报名设置',
          bgColor: ThemeColor.lineF4F5F7Color,
          childWidget: Column(
            children: [
              const SizedBox(
                height: 29,
              ),
              signUpItemView('images/scan/sign_up_name.png',
                  leftName: '姓名', placeName: '请输入姓名'),
              const SizedBox(
                height: 14,
              ),
              signUpItemView('images/scan/sign_up_phone.png',
                  leftName: '电话', placeName: '请输入电话'),
            ],
          ),
        ),
        Positioned(
          bottom: 0,
          left: 0,
          right: 0,
          height: 84,
          child: Container(
            color: Colors.white,
            child: Column(
              children: [
                Container(
                  height: 1,
                  color: ThemeColor.dividerColor,
                ),
                GestureDetector(
                  onTap: () {
                    if (nameController.text.isNotEmpty &&
                        phoneController.text.isNotEmpty) {
                      if (widget.callBack != null) {
                        widget.callBack!();
                      }
                    }
                  },
                  child: Container(
                    height: 40,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(30),
                        color: ThemeColor.appColor),
                    margin: const EdgeInsets.symmetric(
                        horizontal: 58, vertical: 20),
                    alignment: Alignment.center,
                    child: const Text(
                      '完成',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 18,
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }

  Widget signUpItemView(
    String imgStr, {
    String leftName = '',
    String placeName = '',
    TextEditingController? inputController,
  }) {
    return Container(
      color: Colors.white,
      padding: const EdgeInsets.symmetric(vertical: 11, horizontal: 10),
      margin: const EdgeInsets.symmetric(horizontal: 14),
      child: Row(
        children: [
          Image.asset(
            imgStr,
            width: 22,
          ),
          Text(
            leftName,
            style: TextStyle(color: ThemeColor.black1414Color, fontSize: 14),
          ),
          Expanded(child: Container()),
          SizedBox(
            width: 100,
            child: TextField(
              controller: inputController,
              textAlign: TextAlign.end,
              decoration: InputDecoration(
                border: InputBorder.none,
                isCollapsed: true,
                hintText: placeName,
                hintStyle: const TextStyle(fontSize: 14),
              ),
            ),
          )
        ],
      ),
    );
  }
}
